
// 获取当前终端
function getBrowserInfo() {
    var agent = navigator.userAgent.toLowerCase();
    var regStr_ie = /msie [\d.]+;/gi;
    var regStr_ff = /firefox\/[\d.]+/gi
    var regStr_chrome = /chrome\/[\d.]+/gi;
    var regStr_saf = /safari\/[\d.]+/gi;
    var regStr_android= /android\/[\d.]+/gi;
    var regStr_iPhone = /iPhone\/[\d.]+/gi;
    var regStr_iPad = /iPad\/[\d.]+/gi;
    var regStr_webApp = /webApp\/[\d.]+/gi;

//IE
    if (agent.indexOf("msie") > 0) {
        return agent.match(regStr_ie);
    }

//firefox
    if (agent.indexOf("firefox") > 0) {
        return agent.match(regStr_ff);
    }

//Chrome
    if (agent.indexOf("chrome") > 0) {
        return agent.match(regStr_chrome);
    }

//Safari
    if (agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0) {
        return agent.match(regStr_saf);
    }
//android
    if (agent.indexOf("Android") > -1  && agent.indexOf("Linux") > -1 ) {
        return agent.match(regStr_android);
    }
//iPhone
    if (agent.indexOf("iPhone") > -1  && agent.indexOf("Mac") > -1 ) {
        return agent.match(regStr_iPhone);
    }
//iPad
    if (agent.indexOf("iPad") > -1 ) {
        return agent.match(regStr_iPad);
    }
//webApp
    if (agent.indexOf("webApp") > -1  ) {
        return agent.match(regStr_webApp);
    }

}
// 　获取当前时间
function getNowDate() {
    var date = new Date();
    var sign1 = "-";
    var sign2 = ":";
    var year = date.getFullYear() // 年
    var month = date.getMonth() + 1; // 月
    var day = date.getDate(); // 日
    var hour = date.getHours(); // 时
    var minutes = date.getMinutes(); // 分
    var seconds = date.getSeconds() //秒
    var weekArr = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天'];
    var week = weekArr[date.getDay()];
    // 给一位数数据前面加 “0”
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (day >= 0 && day <= 9) {
        day = "0" + day;
    }
    if (hour >= 0 && hour <= 9) {
        hour = "0" + hour;
    }
    if (minutes >= 0 && minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds >= 0 && seconds <= 9) {
        seconds = "0" + seconds;
    }
    var currentdate = year + sign1 + month + sign1 + day + " " + hour + sign2 + minutes + sign2 + seconds + " " + week;
    return currentdate;
}

$.ajax({
    type: 'post',
    url: 'http://dragon.fanqinglong.com:8888/visitor',
    data: {
        date: getNowDate(),
        IP: returnCitySN["cip"],
        CID: returnCitySN["cid"],
        city: returnCitySN["cname"],
        browser: getBrowserInfo()
    },
    success: function () {
        console.log("留下足迹");
    },
    error: function (error) {
        console.log(error);
    }
})